home *** CD-ROM | disk | FTP | other *** search
- UNIT HandleChars;
-
- INTERFACE
-
- USES
- Globals, GPLib;
-
- PROCEDURE DisplayChar (charread : char);
- PROCEDURE Put_Char (tempchar : integer;
- CharRead : Char);
- PROCEDURE Handle_keys (keyPressed : Char);
- PROCEDURE Get_comm_input;
-
- IMPLEMENTATION
-
- PROCEDURE DisplayChar; {(charread : char)}
- BEGIN
- gotoxy(column, row);
- drawchar(charread);
- column := column + 1;
- END;
-
- PROCEDURE Put_Char; { (tempchar : integer;CharRead : Char)}
-
- BEGIN
- CASE tempchar OF
- CrRtn, LineFeed :
- BEGIN
- IF row <= windowlines THEN
- row := row + 1
- ELSE
- BEGIN
- ScrollRect(thePort^.portRect, 0, -12, Urgn);
- END;
- Column := 1;
- gotoxy(column, row);
- END;
- OTHERWISE
- DisplayChar(CharRead);
- END; {tempchar}
- END;
-
- {------------ handle all keyDown events, including command-keys --------------}
- PROCEDURE Handle_keys; {(keyPressed : Char)}
-
- VAR
- oneChar : LongInt;
- charAddr : Ptr;
-
- BEGIN
- onechar := 1;
- charAddr := POINTER(1 + ORD4(@keyPressed)); {char in low-order byte of word}
-
- err := FSWrite(outRefNum, oneChar, charAddr); {send out serial port}
- END; {Handle_keys}
-
-
- { get the next character from the input buffer currently selected }
-
- PROCEDURE GetChar (VAR xchar : char);
- VAR
- errorCode : Integer;
-
- BEGIN
- errorCode := FSRead(inRefNum, oneCount, filterBuffPtr);
- Xchar := Chr(filterBuffPtr^); { get the character pointed to by filterBuffPtr }
- BitClr(@XChar, 8); {clear the high bit for ascii data, not used for binary data}
- END;
-
- {-------------------get characters from serial port, and filter ---------------}
-
- PROCEDURE Get_comm_input;
-
- VAR
- errorCode, tempchar : INTEGER;
- inCount : LongInt;
-
- BEGIN
- errorCode := SerGetBuf(inRefNum, inCount); {get # of char in input buffer}
-
- (* ------- use the code below to very SLOWLY strip line feed characters --------- *)
- IF inCount > 0 THEN
- BEGIN
- GetChar(Charread);
- IF ord(charRead) <> 0 THEN
- BEGIN
- tempchar := BitAnd(ord(charRead), 127); { clear the high bit }
- IF (portA) THEN
- setport(windowB) { we are writing out port A, we are reading port B }
- ELSE
- setport(windowA); { we are writing out port B, we are reading port A }
- Put_Char(tempchar, charRead)
- END; {if charRead}
- END; {if incount}
- END; {Get_Comm_input}
- END.